<?php


function getRss(){
	$rss  = getRssHeader();
	$rss .= getRssItems();
	$rss .= getRssFooter();
	return $rss;
}

function getRssHeader(){
	$rssHeader  = '<rss version="2.0"
	xmlns:media="http://search.yahoo.com/mrss/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
	<title>My Website </title>
	<link>http://wiki.techfandu.org/eduvid/open-cooliris/</link>
	<description>My Website is a great collection of my things.</description>
	<language>en-us</language>
	<lastBuildDate>' . date("D, d M Y h:i:s") . ' EST</lastBuildDate>
	<atom:link href="http://wiki.techfandu.org/eduvid/open-cooliris/generatefeed.php" rel="self" type="application/rss+xml" />
	';


	return $rssHeader;
}

function getRssFooter(){
	$rssFooter .= '  </channel> </rss>';
	return $rssFooter;
}

function getRssItems(){
	$dir = "images/";
	$files = scandir($dir);
	$content = "";
	foreach ($files as $file){
		$file_lowercase = strtolower($file);
		if (substr($file_lowercase, -3) == 'png'){
			$rssItems .= "<item>
			<title>" .$file.  "</title>
			<link>http://wiki.techfandu.org/eduvid/open-cooliris/".$dir.$file."</link>
			<media:thumbnail url=\"http://wiki.techfandu.org/eduvid/open-cooliris/".$dir.$file."\"/>
			<media:content   url=\"http://wiki.techfandu.org/eduvid/open-cooliris/".$dir.$file ."\"/>
			<guid isPermaLink=\"false\">".$file."</guid>
			</item>\r\n";
		}//if
	}//foreach
	return $rssItems;
	}//getrsssitems
	header('Content-Type: text/xml');
	echo getRss();
?>
